home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH05 / PGM5_7.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-10-14  |  2.4 KB  |  127 lines

  1. ; Structures Containing Structures as fields
  2. ; Structures Containing Arrays as fields
  3. ;
  4. ; Randall Hyde
  5.  
  6.  
  7. dseg        segment    para public 'data'
  8.  
  9. Point        struct
  10. X        word    ?
  11. Y        word    ?
  12. Point        ends
  13.  
  14. ; We can define a rectangle with only two points.
  15. ; The color field contains an eight-bit color value.
  16. ; Note: the size of a Rect is 9 bytes.
  17.  
  18. Rect        struct
  19. UpperLeft    Point    {}
  20. LowerRight    Point    {}
  21. Color        byte    ?
  22. Rect        ends
  23.  
  24. ; Pentagons have five points, so use an array of points to
  25. ; define the pentagon.  Of course, we also need the color
  26. ; field.
  27. ; Note: the size of a pentagon is 21 bytes.
  28.  
  29. Pent        struct
  30. Color        byte    ?
  31. Pts        Point    5 dup ({})
  32. Pent        ends
  33.  
  34.  
  35. ; Okay, here are some variable declarations:
  36.  
  37. Rect1        Rect    {}
  38. Rect2        Rect    {{0,0}, {1,1}, 1}
  39.  
  40. Pentagon1    Pent    {}
  41. Pentagons    Pent    {}, {}, {}, {}
  42.  
  43. Index        word    2
  44.  
  45. dseg        ends
  46.  
  47.  
  48. cseg        segment    para public 'code'
  49.         assume    cs:cseg, ds:dseg
  50.  
  51. Main        proc
  52.         mov    ax, dseg    ;These statements are provided by
  53.         mov    ds, ax        ; shell.asm to initialize the
  54.         mov    es, ax        ; segment register.
  55.  
  56. ; Rect1.UpperLeft.X := Rect2.UpperLeft.X
  57.  
  58.         mov    ax, Rect2.Upperleft.X
  59.         mov    Rect1.Upperleft.X, ax
  60.  
  61. ; Pentagon1 := Pentagons[Index]
  62.  
  63.         mov    ax, Index    ;Need Index*21
  64.         mov    bx, 21
  65.         mul    bx
  66.         mov    bx, ax
  67.  
  68. ; Copy the first point:
  69.  
  70.         mov    ax, Pentagons[bx].Pts[0].X
  71.         mov    Pentagon1.Pts[0].X, ax
  72.  
  73.         mov    ax, Pentagons[bx].Pts[0].Y
  74.         mov    Pentagon1.Pts[0].Y, ax
  75.  
  76. ; Copy the second point:
  77.  
  78.         mov    ax, Pentagons[bx].Pts[2].X
  79.         mov    Pentagon1.Pts[4].X, ax
  80.  
  81.         mov    ax, Pentagons[bx].Pts[2].Y
  82.         mov    Pentagon1.Pts[4].Y, ax
  83.  
  84. ; Copy the third point:
  85.  
  86.         mov    ax, Pentagons[bx].Pts[4].X
  87.         mov    Pentagon1.Pts[8].X, ax
  88.  
  89.         mov    ax, Pentagons[bx].Pts[4].Y
  90.         mov    Pentagon1.Pts[8].Y, ax
  91.  
  92. ; Copy the fourth point:
  93.  
  94.         mov    ax, Pentagons[bx].Pts[6].X
  95.         mov    Pentagon1.Pts[12].X, ax
  96.  
  97.         mov    ax, Pentagons[bx].Pts[6].Y
  98.         mov    Pentagon1.Pts[12].Y, ax
  99.  
  100. ; Copy the fifth point:
  101.  
  102.         mov    ax, Pentagons[bx].Pts[8].X
  103.         mov    Pentagon1.Pts[16].X, ax
  104.  
  105.         mov    ax, Pentagons[bx].Pts[8].Y
  106.         mov    Pentagon1.Pts[16].Y, ax
  107.  
  108. ; Copy the Color:
  109.  
  110.         mov    al, Pentagons[bx].Color
  111.         mov    Pentagon1.Color, al
  112.  
  113.  
  114. Quit:        mov    ah, 4ch        ;Magic number for DOS
  115.         int    21h        ; to tell this program to quit.
  116. Main        endp
  117. cseg        ends
  118.  
  119. sseg        segment    para stack 'stack'
  120. stk        byte    1024 dup ("stack   ")
  121. sseg        ends
  122.  
  123. zzzzzzseg    segment    para public 'zzzzzz'
  124. LastBytes    byte    16 dup (?)
  125. zzzzzzseg    ends
  126.         end    Main
  127.